using System;
using System.Collections.Generic;
using System.Text;

namespace Mud.Common
{
    /// <summary>
    /// Used for formating values for string output.
    /// </summary>
    public static class TimeFormater
    {



        /// <summary>
        /// Formats the date time.
        /// </summary>
        /// <param name="dateTime">The date time.</param>
        public static string FormatDateTime(DateTime dateTime)
        {
            return dateTime.ToString("yyyy-MM-dd HH:mm:ss.ff");
        }

        /// <summary>
        /// Gets or sets the index of the starting time.
        /// </summary>
        /// <value>The index of the starting time.</value>
        public static int StartingTimeIndex
        {
            get { return _startingTimeIndex; }
            set { _startingTimeIndex = value; }
        }
        private static int _startingTimeIndex;


        /// <summary>
        /// Formats the index of the time.
        /// </summary>
        /// <param name="index">The index.</param>
        public static string FormatTimeIndex(int index)
        {
            TimeSpan span = TimeSpan.FromMilliseconds(index - _startingTimeIndex);

            return string.Format("{0}:{1}:{2}.{3}", span.Hours, span.Minutes, span.Seconds, span.Milliseconds);
        }

        /// <summary>
        /// Formats the index of the time.
        /// </summary>
        /// <param name="index">The index.</param>
        /// <param name="reference">Reference index</param>
        public static string FormatTimeIndex(int index, int reference)
        {
            TimeSpan span = TimeSpan.FromMilliseconds(index - reference);
            return string.Format("{0}:{1}:{2}.{3}", span.Hours, span.Minutes, span.Seconds, span.Milliseconds);
        }


    }
}
